# !/usr/bin/env python
# coding=utf-8
# @Time    : 2018/7/15 22:19
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/rpc_dao.git
# @File    : my_decorator.py
# @Software: PyCharm
# @Version: 2.7.5
from functools import wraps
from idl_output.ttypes import RequestException
import traceback
from configs import current_config


def aaa():
	raise RequestException('aaa', 'bbb')


def handle_exception():
	def decorator(f):
		@wraps(f)
		def decorated_function(*args, **kwargs):
			try:
				return f(*args, **kwargs)
			except Exception as e:
				print('exception:' + f.__name__ + ' error:' + repr(e))
				print(traceback.print_exc())
				raise RequestException('aaa', 'bbb')

		return decorated_function

	return decorator
